using System;
using System.Web;
using System.Data;
using System.Data.OleDb;
using System.Data.OracleClient;


namespace lib
{
	public class myDBconn2
	{
			
		public  static  DataTable myORATable2(string SQL) 
	{
		
		OracleConnection cn;
		DataSet dsTemp;
		OracleDataAdapter dsCmd;
		string	ConnStr=GlobalVar2.oraConnStr ; 
		
		cn = new OracleConnection(ConnStr);			
		
		dsCmd = new OracleDataAdapter(SQL, cn);
		dsTemp = new DataSet();
		dsCmd.Fill(dsTemp, "Query");
		cn.Close();
		
		return dsTemp.Tables[0];
		
	}

		public  static  long Execute2(string SQL) 
		{			
			string ConnSt;
			OleDbConnection  cn;
			ConnSt = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + GlobalVar2.root + "persistent\\ccapps.mdb";
			
			cn =new OleDbConnection(ConnSt);
			OleDbCommand objCmd =new OleDbCommand(SQL, cn);
			long lngResult = 0;
			
			objCmd.Connection.Open();
			lngResult = objCmd.ExecuteNonQuery();
			cn.Close();
			return lngResult;
		}


		public  static  long ORAExecute2(string SQL) 
		{						
			OracleConnection   cn;

			cn =new OracleConnection(GlobalVar2.oraConnStr);
			OracleCommand objCmd =new OracleCommand(SQL, cn);
			long  lngResult = 0;
			objCmd.Connection.Open();
			lngResult = objCmd.ExecuteNonQuery();
			cn.BeginTransaction().Commit();
			cn.Close();
			return lngResult;		
		}


		public  static  Object ORAScalar2(string p_SQL) 
		{
			OracleConnection l_cn;
			DataSet l_dsTemp;
			OracleDataAdapter l_dsCmd;
			Object l_retval;
			l_cn = new OracleConnection(GlobalVar2.oraConnStr);
			l_dsCmd = new OracleDataAdapter(p_SQL, l_cn);
			l_dsTemp = new DataSet();
			l_dsCmd.Fill(l_dsTemp, "Query");
			l_cn.Close();
			try
			{
				l_retval = (Object)(l_dsTemp.Tables[0].Rows[0][0]);
			} 
			catch(Exception ex) 
			{
					String l_dummy;
					l_dummy = ex.Message;
					l_retval = DBNull.Value;
			}																	
			
			l_dsTemp.Dispose();
			return l_retval;
		}


		
	}
}
